package cn.wpp;


/*
 * 同步线程的两种方式
 * 第一种是实现
 * */
class test3 implements Runnable {
    private static int taket = 100;

    @Override
    public void run() {
        show();
    }

    public synchronized void show() {

        if (taket > 0) {
            System.out.println(Thread.currentThread().getName() + ":" + taket);
        }
        taket--;
    }

}


public class SnychornizedMethod {

    public static void main(String args[]) {
        test test = new test();
        Thread thread1 = new Thread(test);
        Thread thread2 = new Thread(test);
        Thread thread3 = new Thread(test);

        thread1.start();
        thread2.start();
        thread3.start();
    }

}
